#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const { program } = require('commander');
program.version('0.0.1');
program.enablePositionalOptions();

const db_manager = require(__dirname + '/lib/db_manager');
// const eth = require(__dirname + '/lib/eth');
const zth = require(__dirname + '/lib/zth');
const contract = require('./lib/contract');

(async function () {
  // global options
  program
    .passThroughOptions()
    .option('--datadir <datadir>',
            'data directory, default from env.ZETHER_DATADIR',
            process.env.ZETHER_DATADIR);

  // eth.before_parse(program);
  zth.before_parse(program);
  contract.before_parse(program);

  try {
    await program.parseAsync(process.argv);
  } catch (err) {
    console.error('FATAL:', err.message);
  }

  // eth.after_parse(program);
  zth.after_parse(program);
  contract.after_parse(program);
})();
